﻿using Service.Repository;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Service.Auth.Domain.AggregatesModel
{

    /// <summary>
    /// 
    /// </summary>
    [SugarTable("tb_persisted_grant")]
    public class TPersistedGrant : Entity, IAggregateRoot
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="key"></param>
        /// <param name="type"></param>
        /// <param name="subjectId"></param>
        /// <param name="sessionId"></param>
        /// <param name="clientId"></param>
        /// <param name="description"></param>
        /// <param name="creationTime"></param>
        /// <param name="expiration"></param>
        /// <param name="consumedTime"></param>
        /// <param name="data"></param>
        public TPersistedGrant(string key, string type, string subjectId, string? sessionId, string clientId, string? description, DateTime creationTime, DateTime? expiration, DateTime? consumedTime, string data)
        {
            Key = key;
            Type = type;
            SubjectId = subjectId;
            SessionId = sessionId;
            ClientId = clientId;
            Description = description;
            CreationTime = creationTime;
            Expiration = expiration;
            ConsumedTime = consumedTime;
            Data = data;
        }

        public TPersistedGrant()
        {
        }

        [SugarColumn(ColumnName = "key", IsPrimaryKey = true)]
        public string Key { get; private set; }

        [SugarColumn(ColumnName = "type")]
        public string Type { get; private set; }

        [SugarColumn(ColumnName = "subject_id")]
        public string SubjectId { get; private set; }

        [SugarColumn(ColumnName = "session_id")]
        public string? SessionId { get; private set; }

        [SugarColumn(ColumnName = "client_id")]
        public string ClientId { get; private set; }

        [SugarColumn(ColumnName = "description")]
        public string? Description { get; private set; }

        [SugarColumn(ColumnName = "creation_time")]
        public DateTime CreationTime { get; private set; }

        [SugarColumn(ColumnName = "expiration")]
        public DateTime? Expiration { get; private set; }

        [SugarColumn(ColumnName = "consumed_time")]
        public DateTime? ConsumedTime { get; private set; }

        [SugarColumn(ColumnName = "data")]
        public string Data { get; private set; }
    }
}
